package org.anachronos.jeep.probec;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.Writer;

import org.anachronos.jeep.probec.model.ProbeType;
import org.antlr.stringtemplate.StringTemplate;
import org.antlr.stringtemplate.StringTemplateGroup;

public class ClassAdapterGenerator {
	public void generate(final Writer writer, final ProbeType probeType) throws IOException  {
		final InputStream resourceAsStream = 
			Probec.class.getResourceAsStream("ClassAdapter.stg");
		final Reader reader = new InputStreamReader(resourceAsStream);
		final StringTemplateGroup templates = new StringTemplateGroup(reader);

		final StringTemplate template = templates.getInstanceOf("file");
		template.setAttribute("probeType", probeType);
		final String srcFileAsString = template.toString();
		writer.append(srcFileAsString);
	}
}
